<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">

<meta charset="utf-8" />
<title></title>

<meta name="description" content="overview & stats" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="static/css/bootstrap.min.css" />
<link rel="stylesheet" href="static/css/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="static/css/font-awesome.min.css" />
<!--[if IE 7]><link rel="stylesheet" href="css/font-awesome-ie7.min.css" /><![endif]-->
<!--[if lt IE 9]><link rel="stylesheet" href="css/ace-ie.min.css" /><![endif]-->


<link rel="stylesheet" href="static/css/ace.min.css" />
<link rel="stylesheet" href="static/css/ace-responsive.min.css" />
<link rel="stylesheet" href="static/css/ace-skins.min.css" />
<link rel="stylesheet" href="static/css/datepicker.css" /><!-- 日期框 -->
<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
<!--提示框-->
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
<script type="text/javascript">
	$(window.parent.hangge());
	
	//保存
	function save() {
		if($("#version_name").val()==""){
			$("#version_name").tips({
				side:3,
	            msg:'输入版本名称',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#version_name").focus();
			return false;
		}
		
		if($("#version_code").val()==""){
			$("#version_code").tips({
				side:3,
	            msg:'输入版本号',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#version_code").focus();
			return false;
		}else{
			var version_code = $("#version_code").val();
			
			if(isNaN(version_code)){
				$("#version_code").tips({
					side:3,
		            msg:'版本号必须是数值',
		            bg:'#AE81FF',
		            time:3
		        });
				$("#version_code").focus();
				return false;
			}
		}
		
		if($("#url").val()=="" && $("#url_android").val()==""){
			//alert($("#type").val());
			if($("#type").val()==1){
				$("#url_android").tips({
					side:3,
		            msg:'请上传文件',
		            bg:'#AE81FF',
		            time:2
		        });
				
				$("#url_android").focus();
				return false;
			}else{
				$("#url").tips({
					side:3,
		            msg:'输入下载地址',
		            bg:'#AE81FF',
		            time:2
		        });
				
				$("#url").focus();
				return false;
			}
		}
		
		if($("#description").val()==""){
			$("#description").tips({
				side:3,
	            msg:'输入更新说明',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#description").focus();
			return false;
		}

		$("#form1").submit();
		$("#centerOfMainFrame").hide();
		$("#centerOfMainFrame2").show();
	}
	
	
	function changeSystem(type) {
		//alert(type);
		if(type==0){
			$("#android_ios").css('display','');  
			$("#android_choose").css('display', 'none');
		}else{
			$("#android_ios").css('display', 'none'); 
			$("#android_choose").css('display', '');
		}
	}
</script>
</head>
<body>
	<form action="version/addVersion.do" name="form1" id="form1" method="post" enctype="multipart/form-data">
		<div id="centerOfMainFrame">
			<table>
				<tr>
					<td>版本名称:</td>
					<td><input type="text" name="version_name" id="version_name"
						placeholder="这里输入版本名称" title="版本名称" /></td>
				</tr>
				<tr>
					<td>版本号:</td>
					<td><input type="text" name="version_code" id="version_code"
						placeholder="这里输入版本号" title="版本号" /></td>
				</tr>
				<tr id="android_ios" style="display: none;">
					<td>下载地址:</td>
					<td><input type="text" name="url" id="url"
						placeholder="这里输入下载地址" title="下载地址" /></td>
				</tr>
				<tr id="android_choose">
					<td>上传文件:</td>
					<td><input type="file" id="url_android" name="url_android"/></td>
				</tr>
				<tr>
					<td>版本状态:</td>
					<td>
						<select id="isactive" name="isactive" title="版本状态">
							<option value="1">上线</option>
							<option value="0">下线</option>
						</select>	
					</td>
				</tr>
				<tr>
					<td>操作系统:</td>
					<td>
						<select id="type" name="type" title="操作系统" onchange="changeSystem(this.value);">
							<option value="1">ANDROID</option>
							<option value="2">IOS</option>
						</select>	
					</td>
				</tr>
				<tr>
					<td>是否强制升级:</td>
					<td>
						<select id="force_upgrade" name="force_upgrade" title="是否强制升级">
							<option value="1">强制</option>
							<option value="0">不强制</option>
						</select>	
					</td>
				</tr>
				<tr>
					<td>更新说明:</td>
					<td>
						<textarea style="width:93%;height:290px" name="description" id="description"></textarea>
					</td>
				</tr>
				<tr>
					<td>发布日期:</td>
					<td>
						<input class="span10 date-picker" name="release_date" id="release_date" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" placeholder="发布日期" title="发布日期"/>
					</td>
				</tr>
				<tr>
					<td style="text-align: center;"><a
						class="btn btn-mini btn-primary" onclick="save();">保存</a> <a
						class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
					</td>
				</tr>
			</table>
		</div>
	</form>

	<div id="centerOfMainFrame2" class="center" style="display: none">
		<img src="static/images/jzx.gif" style="width: 50px;" /><br />
		<h4 class="lighter block green"></h4>
	</div>
	<!-- 引入 -->
	<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
	<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
	<script type="text/javascript" src="static/js/ace.min.js"></script>
	<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 单选框 -->
	<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
	<script type="text/javascript">
	$(top.hangge());
	$(function() {
		
		//单选框
		$(".chzn-select").chosen(); 
		$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
		
		//日期框
		$('.date-picker').datepicker();
		
		//上传
		$('#url_android').ace_file_input({
			no_file:'请选择文件 ...',
			btn_choose:'选择',
			btn_change:'更改',
			droppable:false,
			onchange:null,
			thumbnail:false //| true | large
			//whitelist:'gif|png|jpg|jpeg'
			//blacklist:'exe|php'
			//onchange:''
			//
		});
	});
	</script>
</body>
</html>
